<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/9/25
 * Time: 11:23
 */
namespace app\admin\model;
use think\Model;
use think\Db;
class Team extends Model
{
    // 确定链接表名
    protected $name = 'team';
    /**
     * 根据搜索条件获取所有的入驻酒店数量
     * @param $where
     */
    public function getAllTeam($where)
    {
        return $this->where($where)->count();
    }
    /**
     * 查询入驻酒店信息
     * @param $where
     * @param $offset
     * @param $limit
     */
    public function getTeamByWhere($where, $offset, $limit)
    {
        $resultData = $this->where($where)->limit($offset, $limit)->order('team_id desc')->select();
		if(count((array)$resultData)>0){
			foreach($resultData as $k => $v){
			  $resultData[$k]['app_time'] = date('Y-m-d H:i:s',$v['app_time']);
              if($v['examine_time']){
                $resultData[$k]['examine_time'] = date('Y-m-d H:i:s',$v['examine_time']);
               }else{
                $resultData[$k]['examine_time'] = "未设置";
               }
              }
		}
		return $resultData;
    }
    /**
     * 入住通过不通过
     * @param $where 条件
     * @param $status 1,2
     */
    public function  isPass($where,$data)
    {
        try{
            $result = $this->where($where)->setField($data);
            if(false === $result){
                // 验证失败 输出错误信息
                return 0;
            }else{
                return 1;
            }
        }catch(\Exception $e){
            return  $e->getMessage();
        }
    }

}